﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Models;
using MvcApplication1.WebService;
using MvcApplication1;

namespace MvcApplication1.Controllers
{
    public class HomeController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            wcfservice.ServiceClient wcfserv = new wcfservice.ServiceClient();
            
            WebService.WebServiceSoapClient ws = new WebServiceSoapClient();
            HomeModel model = new HomeModel(ws.HelloWorld(), ws.Add(1, 2), ws.subtract(7, 3), ws.Multiply(2, 4), ws.Divide(6.2, 3.7), wcfserv.GetData());

            return View(model);
        }

        [HttpPost]
        public ActionResult Index(HomeModel model) {
            ModelState.Clear();
            WebService.WebServiceSoapClient ws = new WebServiceSoapClient();
            wcfservice.ServiceClient wcfserv = new wcfservice.ServiceClient();
            HomeModel new_model = new HomeModel(ws.HelloWorld(), ws.Add(model.a, model.b), ws.subtract(model.a, model.b), ws.Multiply(model.a, model.b), ws.Divide(model.a, model.b), wcfserv.GetData());
            
            return View(new_model);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
